import React from 'react';
import {Row, Col, Collapse, Spin, Icon, Popconfirm, Button, DatePicker, InputNumber, Tooltip, message, Tag, Divider, Popover} from 'antd';
import moment from 'moment';
import { messages, getApprovelHistory, queryCurrencyPrecision } from 'share/common';
import travelService from 'containers/request/travel-request/travel.service';
import requestService from 'containers/request/request.service'
import customField from 'share/customField';
import baseService from 'share/base.service';
const Panel = Collapse.Panel;
import disabledImgZH from 'images/travel/disabled.png';
import disabledImgEN from 'images/travel/disabled-en.png';
import carIconImg from 'images/travel/car.png';
import diningIconImg from 'images/dining.png';
import didiIconImg from 'images/travel/didi.png';
import ctripIconImg from 'images/travel/ctrip.png';
import traffic_line from 'images/request/travel/traffic_line.png';
import TravelOrderList from 'containers/request/travel-request/travel-order-list'
import config from "config";
import {getToken} from 'share/common'
export default {
  /**
   * 生成某日期之后的某一天日期
   * @param afterDays 当前日期之后的天数
   * @param dateStr 日期字符串
   * @returns {Date}
   */
  getAfterDate(afterDays, dateStr, type){
    let date = new Date(dateStr);// it's today
    let oneDayTime = afterDays * 24 * 60 * 60 * 1000;// ms
    let newDate = new Date(date.getTime() + oneDayTime);
    if(type === 'utc'){
      return moment(newDate).utc().format();
    }
    return moment(newDate).format('YYYY-MM-DD');
  },

  /**
   * 生成行程记录折叠板；包含 其他、火车、机票行程、智能机票行程
   * @param title 行程标题
   * @param datas 行程记录
   * @param click 进入编辑点击事件回调
   * @param dele  删除回调函数
   * @param start  起始时间，用来计算第几天的基准
   * @param update  更新回调，行程为往返类型时，删除单个操作实际动作是更新操作
   * @param stopAndStart  恢复和停用回调，原行程具有恢复和停用两种操作，而没有了编辑操作
   * @param isChangeVersion  是否是更改操作而来的单子
   * @param type  标记行程类型
   * @returns {XML}
   */
  getTravelRecordHeader(title, datas, click, dele, update, stopAndStart, start, isChangeVersion, type) {
    if (datas.length > 0) {
      let titleImgUrl = this.setItineraryTypeImg(title);
      let editType = title;
      if (type === 'AUTO_FLIGHT') {
        titleImgUrl = require("images/request/travel/plane.png");
        editType = 'auto_flight';
      }
      return (<span><img style={{marginTop:-4}} src={titleImgUrl}/>&nbsp;{title}</span>)
    }
  },
  getTravelRecordContent(title, datas, click, dele, update, stopAndStart, start, isChangeVersion, type, zxUrl) {
    if (datas.length > 0) {
      let editType = title;
      if (type === 'AUTO_FLIGHT') {
        editType = 'auto_flight';
      }
      let isOther = (title === messages('request.key412'/*其他*/));
      const filterMoney = React.Component.prototype.filterMoney;
      const baseCcy = 'CNY';
      return (<div>
        {datas.map((res, index) => {
          let date = moment(res.startDate).format('YYYY.MM.DD') + " " + this.getWeed(new Date(res.startDate).getDay());
          let day = this.calculateDate(start, res.startDate);
          let isGoBack = title !== messages('request.key410'/*火车*/);//是否具有往返行程类型，火车没有往返类型
          if(isGoBack){
            isGoBack = res.itineraryType === 1002;
          }
          const {meiyaFlightOrderDetails, beyondStandardItems, beyondStandardReason} = res;
          const meiyaFlightOrderDetailsLen = meiyaFlightOrderDetails && meiyaFlightOrderDetails.length;
          let airlineArr = [];
          let realEndDate;
          let realEndDateStr;
          let realEndDateStrL;
          if(meiyaFlightOrderDetailsLen) {
            isGoBack = false;
            click = () => {};

            meiyaFlightOrderDetails.map(order => {
              const {journeys} = order;
              journeys && journeys.map((item, i) => {
                const {departureCityName, arrivalCityName} = item;
                const lastCity = airlineArr[airlineArr.length - 1];
                if (i === 0) {
                  departureCityName !== arrivalCityName && airlineArr.push(arrivalCityName);
                } else {
                  departureCityName !== lastCity && airlineArr.push(departureCityName);
                  arrivalCityName !== lastCity && airlineArr.push(arrivalCityName);
                }
              });
              airlineArr.pop();

              if(order.return) { //获取返程日期
                realEndDate = journeys[journeys.length - 1].arrivalDate;
                realEndDateStr = moment(realEndDate).format('YYYY.MM.DD') + " " + this.getWeed(new Date(realEndDate).getDay());
                realEndDateStrL = this.calculateDate(start, realEndDate);
              }
            })
          }
          const airlineStr = airlineArr.join(', ');
          return (
            <div key={title + index} className="type-line-box" disabled={!res.loading} onClick={() => click(res, editType)}>
              <Row>
                <Col span={10}>
                  <Tag color='#4B8DFF'>{messages('request.key462',{arg1:day}/*第{arg1}天*/)}</Tag>
                  {!!realEndDate && <span>
                    ~ <Tag color='#4B8DFF'>{messages('request.key462',{arg1:realEndDateStrL}/*第{arg1}天*/)}</Tag>
                  </span>}
                  <span>
                    {date} {!!realEndDate && <span>~ {realEndDateStr}</span>}
                  </span>
                </Col>

                <Col span={10} className="type-supply">{res.approvalNum ? messages('request.key334'/*行程单号*/) + `:${res.approvalNum}` : ''}</Col>
                <Col span={4} className="type-supply" style={{display: 'none'}}>
                  {res.supplierName && <img src={res.supplierIconUrl}/>}
                  {res.supplierName}
                </Col>
              </Row>
              {
                res.isExtend && res.disabled && <img className="stop-img" src={messages('request.key438'/*ZH*/) === 'EN' ? disabledImgEN : disabledImgZH}/>
              }
              <Row>
                <Col span={16} className="type-city-city">
                  <Row className="locations">
                    {isOther && <Col span={4}>{res.trafficTypeName}</Col>}
                      <span style={{marginRight:6}}>{res.fromCity ? res.fromCity : messages('request.key490')/*不限*/}</span>
                      <span className="line-wrapper">
                        <img src={traffic_line}/>
                        <span className="line-str">
                          <Popover placement="topLeft" content={airlineStr}>{airlineStr}</Popover>
                        </span>
                      </span>
                      <span style={{marginLeft:6}}>{res.toCity ? res.toCity : messages('request.key490')/*不限*/}</span>
                  </Row>
                </Col>
                <Col span={4}>
                  {!!meiyaFlightOrderDetailsLen && <div className="detail-tag detail-render">
                    <Button type="primary" size="small" className="detail-btn" onClick={() => this.handleRefundZx(res.approvalNum, 'airPlane', zxUrl)}>{messages('dashboard.key128')/*查看详情*/}</Button>
                  </div>}
                </Col>
                {/*智能订票中控只读，不能删除，但是可以停用启用*/}
                {!res.isAuto && (
                  <Col span={4} className={res.isExtend ? 'type-stop' : 'type-city-city type-img-delete'}>
                    {
                      res.isExtend ? (!res.isOut ? (
                        <Button size="small" loading={res.loading} type="primary" onClick={(e) => stopAndStart(e, res, editType, index)}>
                          {res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}
                        </Button>
                        ) : null)
                        : ( isGoBack ? (!res.loading ? <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                                                   onConfirm={() => dele(res, title, index)}
                                                                   onCancel={() => update(res, title, index)}
                                                                   okText={messages('request.key439'/*删除往返行程*/)}
                                                                   cancelText={messages('request.key440'/*仅删除该行程*/)}>
                                <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                              </Popconfirm> : <Button shape="circle" loading={res.loading} />) :
                            (res.loading? <Button shape="circle" loading={res.loading} /> :
                                <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                            onConfirm={() => dele(res, title, index)}
                                            okText={messages('request.key211'/*确定*/)}
                                            cancelText={messages('request.key175'/*取消*/)}>
                                  <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                                </Popconfirm>
                            )
                        )
                    }
                  </Col>
                )}
                {res.isAuto && res.isExtend && (
                  <Col span={4} className="type-stop">
                    <Button size="small" loading={res.loading} type="primary" onClick={(e) => stopAndStart(e, res, editType, index)}>
                      {res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}
                    </Button>
                  </Col>
                )}

              </Row>
              {
                res.taxTotalAmount && <Row>
                  <div>
                    <span className="other-label">{messages('mcd.total.tax.amt')}</span>：
                    <span className="other-value">{res.currency} {filterMoney(res.taxTotalAmount, queryCurrencyPrecision(res.currency))}&nbsp;&nbsp;</span>
                    {
                      (res.currency && res.currency !== baseCcy) && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{res.actualCurrencyRate && res.actualCurrencyRate.toFixed(2)} {baseCcy} {filterMoney(res.baseCurrencyAmount, baseCcy)}
                      </span>
                    }
                  </div>
                </Row>
              }
              <Row>
                {res.remark && <div className="remark">{messages('common.remark')}：{res.remark}</div>}
              </Row>
              {beyondStandardReason && <Row className="standard-exceed">
                {beyondStandardItems && beyondStandardItems.length > 0 && <div className="title">{beyondStandardItems.join(', ')}</div>}
                {beyondStandardReason && <div>{messages('zx.exceed.reason'/*理由*/)}：{beyondStandardReason}</div>}
              </Row>}
              {meiyaFlightOrderDetails && <TravelOrderList orderList={meiyaFlightOrderDetails} type="flight" itinerary={res}/>}
            </div>
          )
        })}
      </div>)
    }
  },

  getOtherRecordContent(title, datas, click, dele, update, displayDetail, toBatchChange, amountChange, toSaveChange, toEditSubsidyItem, searchByDate, isHiddenItem, isCancelHiddenItem, subCtrlObj, baseCcy) {
    const filterMoney = React.Component.prototype.filterMoney;
    if (datas.length > 0) {
      return (<div>
        {datas.map((res, index) => {
          const {itineraryKey, itineraryName, idx, currency, fromDate, leaveDate, cityName, hotelName, star, hotelType, optionalReason, roomType, totalPrice,
            fromCity, toCity, departureDate, cabin, discount, taxTotalAmount, baseCurrencyAmount, actualCurrencyRate = '', companyCurrencyRate,
            travelSubsidiesRequestItemDTOs, startDate, endDate, baseCurrency, optionalReasonOfflineAir} = res;
          const dateF = moment(fromDate).format('YYYY.MM.DD') + " " + moment(fromDate).format('dddd');
          const dateL = moment(leaveDate).format('YYYY.MM.DD') + " " + moment(leaveDate).format('dddd');
          const departureDateL = moment(departureDate).format('YYYY.MM.DD') + ' ' + moment(departureDate).format('dddd');
          const night = this.calculateDate(fromDate, leaveDate) - 1;
          const titleImgUrl = this.setItineraryTypeImg(itineraryKey);
          const showForeignCcy = currency && baseCcy !== currency;

          let startDateL = moment(startDate).format('YYYY-MM-DD') + " " + moment(startDate).format('dddd');
          let endDateL = moment(endDate).format('YYYY-MM-DD') + " " + moment(endDate).format('dddd');
          let total = baseCurrency + " " + filterMoney(res.totalBaseCurrencyAmount, queryCurrencyPrecision(baseCurrency), true) + "  ";
          let currentCodeMap = "";
          let codeNum = 0;//币种数；如果仅有一种币种且为本位币，则不显示后面的币种连加（currentMap）
          let codeStr = "";//第一种币种
          for (let key in res.currencyCodeAmountMap) {
            currentCodeMap = currentCodeMap + key + filterMoney(res.currencyCodeAmountMap[key], queryCurrencyPrecision(key), true) + " + ";
            codeNum++;
            if(codeNum === 1){
              codeStr = key;
            }
          }
          currentCodeMap = currentCodeMap.substr(0, currentCodeMap.length - 2);
          if(codeNum === 1 && codeStr === baseCurrency){
            currentCodeMap = '';
          }
          let requestDTOs = travelSubsidiesRequestItemDTOs || [];

          let result = '';
          switch (itineraryKey) {
            case 'airline':
              result = (
                <div key={itineraryName + idx} className="type-line-box" onClick={() => click(res, itineraryName)}>
                  <div><span><img style={{marginTop: -4}} src={titleImgUrl}/>&nbsp;{itineraryName}</span></div>
                  <Row>
                    <Col span={20} className="type-city-city">
                      <Row className="locations">
                        <span style={{marginRight: 6}}>{fromCity}</span>
                        <span className="line-wrapper">
                          <img src={traffic_line}/>
                          <span className="line-str"></span>
                        </span>
                        <span style={{marginLeft: 6}}>{toCity}</span>
                      </Row>
                    </Col>
                    <Col span={4} className={res.isExtend ? 'type-stop' : 'type-city-city type-img-delete'}>
                      {
                        res.loading ? <Button shape="circle" loading/> :
                          <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                      onConfirm={() => dele(res, itineraryName, idx)}
                                      okText={messages('request.key211'/*确定*/)}
                                      cancelText={messages('request.key175'/*取消*/)}>
                            <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                          </Popconfirm>
                      }
                    </Col>
                  </Row>
                  <div>
                    <span className="other-label">{messages('components.key393'/*出发日期*/)}</span>：
                    <span className="other-value">{departureDateL}</span>
                  </div>
                  <div>
                    <span className="other-label">{messages('mcd.cabin.discount'/*舱位及折扣*/)}</span>：
                    <span className="other-value">{cabin} {discount && <span>| {discount}</span>}</span>
                  </div>
                  {
                    !!optionalReasonOfflineAir && <div>
                      <span className="other-label">{messages('mcd.self.flight.reason'/*自选机票理由*/)}</span>：
                      <span className="other-value">{optionalReasonOfflineAir}</span>
                    </div>
                  }
                  <div>
                    <span className="other-label">{messages('mcd.custom.hotel.order.amt'/*含税总金额*/)}</span>：
                    <span className="other-value">{currency} {filterMoney(taxTotalAmount, queryCurrencyPrecision(currency))}&nbsp;&nbsp;</span>
                    {
                      !!showForeignCcy && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{actualCurrencyRate && actualCurrencyRate.toFixed(2)} {baseCcy} {filterMoney(baseCurrencyAmount, baseCcy)}
                      </span>
                    }
                  </div>
                </div>
              );
              break;
            case 'offlineHotel':
              result = (
                <div key={itineraryName + idx} className="type-line-box" onClick={() => click(res, itineraryName)}>
                  <div><span><img style={{marginTop: -4}} src={titleImgUrl}/>&nbsp;{itineraryName}</span></div>
                  <Row>
                    <Col span={20} className="type-city-city"><span>{cityName}</span></Col>
                    <Col span={4} className="type-city-city type-img-delete">
                      {
                        res.loading ? <Button shape="circle" loading/> :
                        <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                   onConfirm={() => dele(res, itineraryName, idx)}
                                   okText={messages('request.key211'/*确定*/)}
                                   cancelText={messages('request.key175'/*取消*/)}>
                          <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                        </Popconfirm>
                      }
                    </Col>
                  </Row>
                  <div>
                    <span className="other-label">{messages('financial-management.key56'/*入住时间*/)}</span>：
                    <span className="other-value">{`${dateF}~${dateL}`} {`${messages('request.key470',{arg1:night}/*{arg1}晚*/)}`}</span>
                  </div>
                  <div>
                    <span className="other-label">{messages('financial-management.key728'/*酒店名称*/)}</span>：
                    <span className="other-value">{hotelName} {!!star && <span>| {messages(`mcd.custom.hotel.star.level${Number(star)}`)}</span>}</span>
                  </div>
                  <div>
                    <span className="other-label">{messages('mcd.hotel.room.type'/*酒店类型及房型*/)}</span>：
                    <span className="other-value">{messages(`mcd.${hotelType}`)} {!!roomType && <span>| {roomType}</span>}</span>
                  </div>
                  {
                    !!optionalReason && <div>
                      <span className="other-label">{messages('mcd.self.reason'/*自选酒店理由*/)}</span>：
                      <span className="other-value">{optionalReason}</span>
                    </div>
                  }
                  <div>
                    <span className="other-label">{messages('mcd.custom.hotel.order.amt'/*含税总金额*/)}</span>：
                    <span className="other-value">{currency} {filterMoney(totalPrice, queryCurrencyPrecision(currency))}&nbsp;&nbsp;</span>
                    {
                      !!showForeignCcy && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{actualCurrencyRate && actualCurrencyRate.toFixed(2)} {baseCcy} {React.Component.prototype.filterMoney(baseCurrencyAmount, baseCcy)}
                      </span>
                    }
                  </div>
                </div>
              );
              break;
            case 'urban':
              result = (
                <div key={itineraryName + idx} className="type-line-box" onClick={() => click(res, itineraryName)}>
                  <div><span><img style={{marginTop: -4, width: '15px'}} src={titleImgUrl}/>&nbsp;{itineraryName}</span></div>
                  <Row>
                    <Col span={20}></Col>
                    <Col span={4} className="type-img-delete">
                      {
                        res.loading ? <Button shape="circle" loading/> :
                          <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                      onConfirm={() => dele(res, itineraryName, idx)}
                                      okText={messages('request.key211'/*确定*/)}
                                      cancelText={messages('request.key175'/*取消*/)}>
                            <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                          </Popconfirm>
                      }
                    </Col>
                  </Row>
                  <div>
                    <span className="other-label">{messages('mcd.total.tax.amt'/*含税总金额*/)}</span>：
                    <span className="other-value">{currency} {filterMoney(taxTotalAmount, queryCurrencyPrecision(currency))}&nbsp;&nbsp;</span>
                    {
                      !!showForeignCcy && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{actualCurrencyRate && actualCurrencyRate.toFixed(2)} {baseCcy} {filterMoney(baseCurrencyAmount, baseCcy)}
                      </span>
                    }
                  </div>
                </div>
              );
              break;
            case 'water':
              result = (
                <div key={itineraryName + idx} className="type-line-box" onClick={() => click(res, itineraryName)}>
                  <div><span><img style={{marginTop: -4, width: '15px'}} src={titleImgUrl}/>&nbsp;{itineraryName}</span></div>
                  <Row>
                    <Col span={20} className="type-city-city">
                      <Row className="locations">
                        <span style={{marginRight: 6}}>{fromCity}</span>
                        <span className="line-wrapper">
                          <img src={traffic_line}/>
                          <span className="line-str"></span>
                        </span>
                        <span style={{marginLeft: 6}}>{toCity}</span>
                      </Row>
                    </Col>
                    <Col span={4} className="type-city-city type-img-delete">
                      {
                        res.loading ? <Button shape="circle" loading/> :
                          <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                      onConfirm={() => dele(res, itineraryName, idx)}
                                      okText={messages('request.key211'/*确定*/)}
                                      cancelText={messages('request.key175'/*取消*/)}>
                            <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                          </Popconfirm>
                      }
                    </Col>
                  </Row>
                  <div>
                    <span className="other-label">{messages('components.key393'/*出发日期*/)}</span>：
                    <span className="other-value">{departureDateL}</span>
                  </div>
                  <div>
                    <span className="other-label">{messages('mcd.total.tax.amt'/*含税总金额*/)}</span>：
                    <span className="other-value">{currency} {filterMoney(taxTotalAmount, queryCurrencyPrecision(currency))}&nbsp;&nbsp;</span>
                    {
                      !!showForeignCcy && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{actualCurrencyRate && actualCurrencyRate.toFixed(2)} {baseCcy} {filterMoney(baseCurrencyAmount, baseCcy)}
                      </span>
                    }
                  </div>
                </div>
              );
              break;
            case 'subsidy':
              result = (
                <div key={itineraryName + idx} className="subsidy-record-css">
                  <div><span><img style={{marginTop: -4}} src={titleImgUrl}/>&nbsp;{itineraryName}</span></div>

                  <div>
                    <span className="other-label">{messages('request.key314'/*出差日期*/)}</span>：
                    <span className="other-value">{`${startDateL} ~ ${endDateL}`}</span>
                  </div>
                  <div>
                    <span className="other-label">{messages('mcd.total.tax.amt'/*含税总金额*/)}</span>：
                    <span className="other-value">{total}&nbsp;&nbsp;</span>
                    {
                      !!showForeignCcy && <span className="other-value">
                        {messages('components.key55'/*汇率*/)}：{actualCurrencyRate && actualCurrencyRate.toFixed(2)} {currentCodeMap}
                      </span>
                    }
                  </div>
                  {
                    requestDTOs.map((req, reqIndex)=> {
                      let displayItem = {index: idx, reqIndex};
                      let currentCodeMapChiled = '';
                      let codeTypeCount = 0;
                      let firstCodeType = '';
                      let isShowCurrentCodeMapChiled = true;
                      for (let key in req.currencyCodeAmountMap) {
                        currentCodeMapChiled = currentCodeMapChiled + key + filterMoney(res.currencyCodeAmountMap[key], queryCurrencyPrecision(key), true) + " + ";
                        codeTypeCount++;
                        if(codeTypeCount === 1){
                          firstCodeType = key;
                        }
                      }
                      if(codeTypeCount === 1 && firstCodeType === req.baseCurrencyCode){
                        isShowCurrentCodeMapChiled = false;
                      }
                      currentCodeMapChiled = currentCodeMapChiled.substr(0, currentCodeMapChiled.length - 2);
                      let totalChiled = req.baseCurrencyCode + " " + filterMoney(req.baseCurrencyAmount, queryCurrencyPrecision(req.baseCurrencyCode), true);
                      let detailMaps = req.travelSubsidiesItemMap;
                      let relativeRepeat = req.duplicateSubsidiesOIDs || [];
                      return (
                        <div className="second-box" key={itineraryName+idx+reqIndex}>
                          {req.status == 1002 && <div className="to-hiden">
                            <span>{messages('request.key444'/*!隐藏该员工该行程下的所有差补，提交后将自动删除隐藏的差补*/)}</span>
                            <span onClick={() => isCancelHiddenItem(req, false)}>
                              {messages('request.key445'/*取消隐藏*/)}
                              <img src={require('images/travel/subsidy-hide.png')}/></span>
                          </div>}
                          <Row className="row-child">
                            <Col span={6}>
                              <span className="other-label">{messages('common.applicant'/*申请人*/)}</span>：
                              <span className="other-value">{req.fullName}</span>
                            </Col>
                            <Col span={16}>
                              {
                                isShowCurrentCodeMapChiled && <Tooltip title={currentCodeMapChiled} placement="top">
                                  <Row className="child-map">{currentCodeMapChiled}</Row>
                                </Tooltip>
                              }
                              <Row className="child-map">{totalChiled}</Row>
                            </Col>
                            <Col span={2} className="display-icon">
                              <Icon type={req.isDisplay ? 'down-circle-o' : 'right-circle-o'}
                                    onClick={() => displayDetail(idx, reqIndex)}/>
                            </Col>
                          </Row>
                          {
                            req.isDisplay && detailMaps.map((det, detIndex)=> {/* TODO 需要一个控制显示的量 */
                              return det.travelSubsidiesRequestItemDetailDTOs.map((detail, indexOf)=> {
                                let date = moment(detail.subsidiesDate).format('MM-DD');
                                let rateMount =  messages('request.key342'/*企业汇率*/)+ ": ";
                                let isRepeat = false;
                                relativeRepeat.map(repeat => {//检验是否重复
                                  if (detail.travelSubsidiesDetailsOID == repeat) {
                                    isRepeat = true;
                                  }
                                })
                                let calculateChar = ' + ';
                                if(detail.currencyRate - detail.baseCurrencyRate < 0){
                                  calculateChar = ' - ';
                                }
                                let tempRate = Math.abs(detail.currencyRate - detail.baseCurrencyRate) / detail.baseCurrencyRate * 100;
                                rateMount = rateMount + detail.baseCurrencyRate.toFixed(2) + calculateChar + tempRate.toFixed(1)
                                  + `% , ${messages('request.key343'/*原金额*/)}: `
                                  + React.Component.prototype.filterMoney(detail.baseAmount, queryCurrencyPrecision(detail.currencyCode), true);
                                return (
                                  <div className="subsidy-detail" key={detail.travelSubsidiesDetailsOID}>
                                    {detail.status == 1002 && <div className="to-hiden">
                                      <span>{messages('request.key446'/*!隐藏的差补在提交后将自动删除*/)}</span>
                                      <span onClick={() => isCancelHiddenItem(detail, true, displayItem)}>
                                        {messages('request.key445'/*取消隐藏*/)}
                                        <img src={require('images/travel/subsidy-hide.png')}/></span>
                                    </div>}
                                    <Spin spinning={subCtrlObj.isSaveChange}>
                                      <Row>
                                        <Col span={3}>{date}</Col>
                                        <Col span={12} className="child-map-detail">
                                          {
                                            isRepeat && <Tag color="#f50">{messages('request.key341'/*重复*/)}</Tag>
                                          }
                                          {detail.expenseTypeName}</Col>
                                        <Col span={2} className="text-center">{detail.currencyRate.toFixed(2)}</Col>
                                        <Col span={2} className="text-center">{detail.currencyCode}</Col>
                                        {
                                          res.isBatch ? <Col span={5}>
                                              {
                                                subCtrlObj.isCanMore ? <InputNumber
                                                    onChange={(e) => amountChange(idx, reqIndex, detIndex, indexOf, e)} min={0}
                                                    defaultValue={detail.amount}/> :
                                                  <InputNumber min={0}
                                                               onChange={(e) => amountChange(idx, reqIndex, detIndex, indexOf, e)}
                                                               precision={queryCurrencyPrecision(detail.currencyCode)}
                                                               max={detail.baseAmount} defaultValue={detail.amount}/>
                                              }

                                            </Col> :
                                            <Col span={2} className="text-center">{React.Component.prototype.filterMoney(detail.amount, queryCurrencyPrecision(detail.currencyCode), true)}</Col>
                                        }
                                      </Row>
                                      <Row style={{marginTop:6}}>
                                        <Col span={3}></Col>
                                        <Col span={19}>{rateMount}</Col>
                                      </Row>
                                      {
                                        detail.comment && <Row style={{marginTop:6}}>
                                          <Col span={3}></Col>
                                          <Col span={19} style={{wordBreak: 'break-all'}}>{messages('request.key364'/*备注*/)+"：" + detail.comment}</Col>
                                        </Row>
                                      }
                                    </Spin>
                                  </div>
                                )
                              })
                            })
                          }
                        </div>
                      )
                    })
                  }
                </div>
              );
              break;
            default:
              result = '';
              break;
          }
          return result;
        })}
      </div>)
    }
  },

  //跳转甄选机票订单详情
  handleRefundZx(approvalNum, vendorCode, zxUrl) {
    // const zxHost = config.zxHosts[location.host] || config.zxHost;
    const realmId = config.realmIds[location.host] || config.realmId;
    const { access_token } = JSON.parse(getToken());
    const url = `${zxUrl}&access_token=${access_token}&pageType=orderDetail&realmId=${realmId}&customerOrderId=${approvalNum}&language=zh&newWindowFlag=Y`;
    console.log(url)
    window.open(url);
  },

//同上，仅包含备注行程，clear方法为清空备注
  getRemarkRecordHeader(title, datas, click, dele, clear, start) {
    if (datas.length > 0 && title === messages('request.key411'/*备注*/)) {
      let isGo = false;
      datas.map(map => {
        if (map.remark || map.itineraryShowDetails.length > 0)
          isGo = true;
      });
      if (isGo) {
        let titleImgUrl = this.setItineraryTypeImg(title);
        return (<span><img style={{marginTop:-4}} src={titleImgUrl}/>&nbsp;{title}</span>)
      }
    }
  },
  getRemarkRecordContent(title, datas, click, dele, clear, start) {
    if (datas.length > 0 && title === messages('request.key411'/*备注*/)) {
      let isGo = false;
      datas.map(map=> {
        if (map.remark || map.itineraryShowDetails.length > 0)
          isGo = true;
      });
      if (isGo) {
        return (<div>
          {datas.map((res, index) => {
            if (res.itineraryShowDetails.length > 0 || res.remark) {
              let date = `${moment(res.remarkDate).format('MM.DD')} ${this.getWeed(new Date(res.remarkDate).getDay())}`;
              let types = res.itineraryType ? JSON.parse(res.itineraryType) : [];
              let day = this.calculateDate(start, res.remarkDate);
              return (
                <div key={title + index} className="type-line-box" onClick={() => click(res, title)}>
                  <Row className="remark-title">
                    <Col span={6}>
                      <Tag color='#4B8DFF'>{messages('request.key462',{arg1:day}/*第{arg1}天*/)}</Tag>{date}
                    </Col>
                    {types.map(item => {
                      let imgUrl = this.setItineraryTypeImg(item);
                      return (<Col span={1} key={imgUrl}><img src={imgUrl}/></Col>)
                    })}
                  </Row>
                  { res.remark && <Row className="remark-item">
                    <Col span={16}>{res.remark}</Col>
                    <Col span={8} className="remark-clear">
                      {
                        res.itineraryShowDetails.length > 0 ?
                          (res.loading ? <Button shape="circle" loading/>: <Popconfirm title={messages('request.key441'/*确定清空该行程备注吗?*/)}
                                                                                       onConfirm={() => clear(res,index)}
                                                                                       okText={messages('request.key211'/*确定*/)}
                                                                                       cancleText={messages('request.key175'/*取消*/)}>
                              <span onClick={(e) => {e.stopPropagation();}}>{messages('request.key394'/*清空*/)}</span>
                            </Popconfirm>)
                          :
                          (res.loading ? <Button shape="circle" loading/> : <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                                                                        onConfirm={() => dele(res,title,index)}
                                                                                        okText={messages('request.key211'/*确定*/)}
                                                                                        cancelText={messages('request.key175'/*取消*/)}>
                              <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                            </Popconfirm>)
                      }
                    </Col>
                  </Row> }
                  {
                    res.itineraryShowDetails.map((detail, remarkIndex) => {
                      return (
                        <Row className="remark-item" key={title+index+remarkIndex}>
                          <Col span={6} className="item-font">
                            <img src={this.setItineraryTypeImg(detail.travelItineraryType)}/>
                            <span style={{marginLeft:4}}>{detail.fromCity}{detail.toCity ? "-"+detail.toCity : ''}</span>
                          </Col>
                          <Col span={12}>
                            {detail.remark}
                          </Col>
                        </Row>
                      )
                    })
                  }
                </div>
              )
            }
          })}
        </div>)
      }
    }
  },

  getDiDiType(approvalType) {
    if (approvalType === 1) {
      return messages('request.key478')/*差旅用车*/;
    }
    if (approvalType === 2) {
      return messages('request.key479')/*按次数用车*/;
    }
    if (approvalType === 3) {
      return messages('request.key480')/*按日期用车*/;
    }
    if (approvalType === 4) {
      return messages('request.key588')/*马上用车*/;
    }
    if (approvalType === 5) {
      return messages('request.key589')/*接送机／火车*/;
    }
    return null;
  },

  /**
   * didi行程card的展示
   * @param title 行程标题
   * @param datas 行程记录
   * @param dele  删除回调函数
   * @param click 进入编辑点击事件回调
   * @param start  起始时间，用来计算第几天的基准
   * @param stopAndStart  恢复和停用回调，原行程具有恢复和停用两种操作，而没有了编辑操作
   * @param isChangeVersion  是否是更改操作而来的单子
   * @returns {XML}
   */
  getDiDiRecordHeader(title, datas, start, dele, click, stopAndStart, isChangeVersion){
    if (datas.length > 0) {
      return (<span><img style={{marginTop:-4, width: 15, height: 15}} src={carIconImg}/>&nbsp;{title}</span>)
    }
  },
  getDiDiRecordContent(title, datas, start, dele, click, stopAndStart, isChangeVersion, mapInfo){
    let standardEnable = mapInfo['ca.travel.applypolicy.enable'] === 'true';
    if (datas.length > 0) {
      return (
        <div>
          {datas.map((res, index) => {
            let dateF = '';
            if (res.startDate) {
              dateF = moment(res.startDate).format('YYYY.MM.DD') + " " + moment(res.startDate).format('dddd');
            } else {
              dateF = messages('request.key591')/*日期不限*/;
            }
            let dateL = '';
            if (res.endDate) {
              dateL = moment(res.endDate).format('YYYY.MM.DD') + " " + moment(res.endDate).format('dddd');
            } else {
              dateL = messages('request.key591')/*日期不限*/;
            }
            let startF = this.calculateDate(start, res.startDate);
            let endL = this.calculateDate(start, res.endDate);
            let startTime = moment(res.startDate).format('HH:mm');
            let endTime = moment(res.endDate).format('HH:mm');
            let trips = [];
            if (res.trips) {
              trips = JSON.parse(res.trips);
            }
            let useCitiesStr = ''; //用车城市
            if ([3, 4, 5].indexOf(res.approvalType) > -1) {
              let useCities = [];
              res.approvalType === 3 && trips.map(trip => {
                useCities.push(trip.destinationCity);
              });
              (res.approvalType === 4 || res.approvalType === 5) && res.travelCarItineraryTrips && res.travelCarItineraryTrips.map(trip => {
                useCities.push(trip.departureCity);
              });
              useCitiesStr = useCities.join('、');
            }
            return (
              <div key={title + index} className="type-line-box" onClick={() => click(res, 'didi')}>
                <Row>
                  <Col span={6}>
                    <Tag color='#4B8DFF' style={{marginRight: 0}}>
                      {res.startDate ? messages('request.key462',{arg1:startF}/*第{arg1}天*/) : messages('request.key591')/*日期不限*/}
                    </Tag>
                    &nbsp;~&nbsp;
                    <Tag color='#4B8DFF'>
                      {res.endDate ? messages('request.key462',{arg1:endL}/*第{arg1}天*/) : messages('request.key591')/*日期不限*/}
                    </Tag>
                  </Col>
                  <Col span={11}>{`${dateF}~${dateL}`}</Col>
                  <Col offset={3} span={4} className="type-supply">
                    {[1, 2, 3].indexOf(res.approvalType) > -1 && (
                      <div>
                        <img src={didiIconImg}/>{messages('request.key482')/*企业滴滴*/}
                      </div>
                    )}
                    {[4, 5].indexOf(res.approvalType) > -1 && (
                      <div>
                        <img src={ctripIconImg}/>{messages('request.key592')/*携程*/}
                      </div>
                    )}
                  </Col>
                </Row>
                {res.isExtend && res.disabled && (
                  <img className="stop-img" src={messages('request.key438'/*ZH*/) === 'EN' ? disabledImgEN : disabledImgZH}/>
                )}
                <Row style={{marginTop: 10}} type="flex" align="middle">
                  <Col span={6}>
                    <span className="font-title">{messages('request.key483')/*用车类型*/}：</span>
                    <span className="font-content">{this.getDiDiType(res.approvalType)}</span>
                  </Col>
                  <Col offset={1} span={14} style={{whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>
                    {res.approvalType < 4 && (
                      <span>
                        <span className="font-title">{messages('request.key484')/*用车制度*/}：</span>
                        <span className="font-content">{res.regulationName}</span>
                      </span>
                    )}
                  </Col>
                  <Col offset={1} span={2} className='type-img-delete-didi'>
                    {res.isExtend ? (
                      <Button size="small" loading={res.loading} type="primary" onClick={(e) => stopAndStart(e, res, 'didi', index)}>{res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}</Button>
                    ) : (res.loading ? (<Button shape="circle" loading/>) : (
                      <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                  onConfirm={() => dele(res, 'didi', index)}
                                  okText={messages('request.key211'/*确定*/)}
                                  cancelText={messages('request.key175'/*取消*/)}>
                        <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                      </Popconfirm>
                    ))}
                  </Col>
                </Row>
                <Divider style={{margin: '10px 0'}} />
                {res.approvalType === 1 && (
                  <Row>
                    <Col span={24}>
                      <span className="font-title">{messages('request.key485')/*行程安排*/}：</span>
                      <span className="font-content-other">{res.departureCity}</span>
                      <img style={{width: 40, margin: '0 10px'}} src={traffic_line}/>
                      {trips.map((trip, tripIndex) => {
                        return (
                          <span key={tripIndex}>
                            <span className="font-content-other">{trip.destinationCity}</span>
                            <img style={{width: 40, margin: '0 10px'}} src={traffic_line}/>
                          </span>
                        )
                      })}
                      <span className="font-content-other">{res.destinationCity}</span>
                    </Col>
                  </Row>
                )}
                {res.approvalType === 2 && (
                  <Row>
                    <Col span={10}>
                      <span className="font-title">{messages('request.key486')/*用车时段*/}：</span>
                      <span className="font-content-other">{startTime}&nbsp;~&nbsp;{endTime}</span>
                    </Col>
                    <Col offset={2} span={10}>
                      <span className="font-title">{messages('request.key487')/*用车次数*/}：</span>
                      <span className="font-content-other">{res.tripTimes}{messages('request.key488')/*次*/}</span>
                    </Col>
                  </Row>
                )}
                {res.approvalType === 3 && (
                  <Row>
                    {!standardEnable && (
                      <Col span={10}>
                        <span className="font-title">{messages('request.key489')/*用车金额*/}：</span>
                        {(res.tripAmount || res.tripAmount === 0) ?
                          <span className="font-content-other">CNY&nbsp;{React.Component.prototype.filterMoney(res.tripAmount)}</span> : <span className="font-content-other">{messages('request.key490')/*不限*/}</span>
                        }
                      </Col>
                    )}
                    <Col offset={standardEnable ? 0 : 2} span={10}>
                      <span className="font-title">{messages('request.key491')/*用车城市*/}：</span>
                      {!!useCitiesStr ?
                        <span className="font-content-other">{useCitiesStr}</span> : <span className="font-content-other">{messages('request.key490')/*不限*/}</span>
                      }
                    </Col>
                  </Row>
                )}
                {res.approvalType === 4 && (
                  <Row gutter={8}>
                    {!standardEnable && (
                      <Col span={8}>
                        <span className="font-title">{messages('request.key489')/*用车金额*/}：</span>
                        {(res.tripAmount || res.tripAmount === 0) ?
                          <span className="font-content-other">CNY&nbsp;{React.Component.prototype.filterMoney(res.tripAmount)}</span> : <span className="font-content-other">{messages('request.key490')/*不限*/}</span>
                        }
                      </Col>
                    )}
                    <Col span={8}>
                      <span className="font-title">{messages('request.key491')/*用车城市*/}：</span>
                      {!!useCitiesStr ?
                        <span className="font-content-other">{useCitiesStr}</span> : <span className="font-content-other">{messages('request.key490')/*不限*/}</span>
                      }
                    </Col>
                    <Col span={8}>
                      <span className="font-title">{messages('request.key487')/*用车次数*/}：</span>
                      {!!res.tripTimes ?
                        <span className="font-content-other">{res.tripTimes}{messages('request.key488')/*次*/}</span> : <span className="font-content-other">{messages('request.key490')/*不限*/}</span>
                      }
                    </Col>
                  </Row>
                )}
                {res.approvalType === 5 && (
                  <Row gutter={8}>
                    <Col span={8}>
                      <span className="font-title">{messages('request.key491')/*用车城市*/}：</span>
                      <span className="font-content-other">{useCitiesStr}</span>
                    </Col>
                    <Col span={8}>
                      <span className="font-title">{messages('request.key593')/*接送类型*/}：</span>
                      <span className="font-content-other">{res.carPickUpTypeDescription}</span>
                    </Col>
                  </Row>
                )}
              </div>
            )
          })}
        </div>
      )
    }
  },

  /**
   * 用餐行程card的展示
   * @param title 行程标题
   * @param datas 行程记录
   * @param dele  删除回调函数
   * @param click 进入编辑点击事件回调
   * @param start  起始时间，用来计算第几天的基准
   * @param stopAndStart  恢复和停用回调，原行程具有恢复和停用两种操作，而没有了编辑操作
   * @param isChangeVersion  是否是更改操作而来的单子
   * @returns {XML}
   */
  getDiningRecordHeader(title, datas, start, dele, click, stopAndStart, isChangeVersion){
    if (datas.length > 0) {
      return (<span><img style={{marginTop:-4, width: 15, height: 15}} src={diningIconImg}/>&nbsp;{title}</span>)
    }
  },

  getDiningRecordContent(title, datas, start, dele, click, stopAndStart, isChangeVersion){
    if (datas.length > 0) {
      return (
        <div>
          {datas.map((res, index) => {
            let dateF = '';
            if (res.startDate) {
              dateF = moment(res.startDate).format('YYYY.MM.DD') + " " + moment(res.startDate).format('dddd');
            } else {
              dateF = messages('request.key591')/*日期不限*/;
            }
            let dateL = '';
            if (res.endDate) {
              dateL = moment(res.endDate).format('YYYY.MM.DD') + " " + moment(res.endDate).format('dddd');
            } else {
              dateL = messages('request.key591')/*日期不限*/;
            }
            let startF = this.calculateDate(start, res.startDate);
            let endL = this.calculateDate(start, res.endDate);
            return (
              <div key={title + index} className="type-line-box" onClick={() => click(res, 'dining')}>
                <Row>
                  <Col span={6}>
                    <Tag color='#4B8DFF' style={{marginRight: 0}}>
                      {res.startDate ? messages('request.key462',{arg1: startF}/*第{arg1}天*/) : messages('request.key591')/*日期不限*/}
                    </Tag>
                    &nbsp;~&nbsp;
                    <Tag color='#4B8DFF'>
                      {res.endDate ? messages('request.key462',{arg1: endL}/*第{arg1}天*/) : messages('request.key591')/*日期不限*/}
                    </Tag>
                  </Col>
                  <Col span={11}>{`${dateF}~${dateL}`}</Col>
                  <Col span={6}>{res.approvalNumber && <span>{messages('request.key334'/*行程单号*/)}：{res.approvalNumber}</span>}</Col>
                </Row>
                {res.isExtend && res.disabled && (
                  <img className="stop-img" src={messages('request.key438'/*ZH*/) === 'EN' ? disabledImgEN : disabledImgZH}/>
                )}
                <Row style={{marginTop: 10}} type="flex" align="middle">
                  <Col span={6}>
                    <span className="font-title">{messages('request.key634')/*用餐类型*/}：</span>
                    <span className="font-content">{res.diningSceneDTO.name}</span>
                  </Col>
                  <Col offset={16} span={2} className='type-img-delete-didi'>
                    {res.isExtend ? (
                        <Button
                          size="small"
                          loading={res.loading}
                          type="primary"
                          onClick={(e) => stopAndStart(e, res, 'dining', index)}
                        >
                          {res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}
                        </Button>
                      ) : (res.loading ? (<Button shape="circle" loading/>) : (
                        <Popconfirm
                          title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                          onConfirm={() => dele(res, 'dining', index)}
                          okText={messages('request.key211'/*确定*/)}
                          cancelText={messages('request.key175'/*取消*/)}
                        >
                          <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                        </Popconfirm>
                      )
                    )}
                  </Col>
                </Row>
                <Divider style={{margin: '10px 0'}} />
                <Row gutter={8}>
                  {res.cityCode && (
                    <Col span={8}>
                      <span className="font-title">{messages('request.key629')/*用餐城市*/}：</span>
                      <span className="font-content-other">{res.cityName}</span>
                    </Col>
                  )}
                  {res.standardAmount && (
                    <Col span={8}>
                      <span className="font-title">{messages('request.key630')/*用餐标准*/}：</span>
                      <span className="font-content-other">CNY&nbsp;{React.Component.prototype.filterMoney(res.standardAmount)}</span>
                    </Col>
                  )}
                </Row>
              </div>
            )
          })}
        </div>
      )
    }
  },

  //同上，仅包含酒店行程
  getHotelRecordHeader(title, datas, click, dele, stopAndStart, start, isChangeVersion){
    if (datas.length > 0 && title === messages('mcd.tmc.hotel'/*TMC酒店*/)) {
      let titleImgUrl = this.setItineraryTypeImg(title);
      return (<span><img style={{marginTop:-4}} src={titleImgUrl}/>&nbsp;{title}</span>)
    }
  },
  getHotelRecordContent(title, datas, click, dele, stopAndStart, start, isChangeVersion, zxUrl){
    if (datas.length > 0 && title === messages('mcd.tmc.hotel'/*TMC酒店*/)) {
      return (<div>
        {
          datas.map((res, index) => {
            let dateF = moment(res.fromDate).format('YYYY.MM.DD') + " " + moment(res.fromDate).format('dddd');
            let dateL = moment(res.leaveDate).format('YYYY.MM.DD') + " " + moment(res.leaveDate).format('dddd');
            let startF = this.calculateDate(start, res.fromDate);
            let endL = this.calculateDate(start, res.leaveDate);
            let night = this.calculateDate(res.fromDate, res.leaveDate) - 1;
            if(res.travelHotelOrderInfoDTOs && res.travelHotelOrderInfoDTOs[0] && res.travelHotelOrderInfoDTOs[0].vendorsOrderStatus) {
              click = () => {};
            }
            const {excessiveMatters, beyondStandardReason, travelHotelOrderInfoDTOs} = res;
            return (
              <div key={title + index} className="type-line-box" onClick={() => click(res, title)}>
                <Row>
                  <Col span={16}>
                    <Tag color='#4B8DFF'>{messages('request.key462',{arg1:startF}/*第{arg1}天*/)}</Tag>~&nbsp;
                    <Tag color='#4B8DFF'>{messages('request.key462',{arg1:endL}/*第{arg1}天*/)}</Tag>
                    {`${dateF} ~ ${dateL}`}
                  </Col>
                  {false && <Col span={3}>{`${messages('request.key470',{arg1:night}/*{arg1}晚*/)}`}</Col>}
                  <Col span={4} className="type-supply" style={{display: 'none'}}>
                    {res.supplierName && <img src={res.supplierIconUrl}/>}
                    {res.supplierName}
                  </Col>
                </Row>
                {
                  res.isExtend && res.disabled && <img className="stop-img" src={messages('request.key438'/*ZH*/) === 'EN' ? disabledImgEN : disabledImgZH}/>
                }
                <Row>
                  <Col span={10} className="type-city-city">
                    {messages('request.key337'/*目的地*/)}：
                    <span>{res.cityName ? res.cityName : messages('request.key490')/*不限*/}</span>
                  </Col>
                  <Col span={6} className="type-city-city">{res.approvalNumber && <div>{messages('request.key334'/*行程单号*/)}：{res.approvalNumber}</div>}</Col>
                  <Col span={4} className="detail-tag detail-render">
                    { !!(travelHotelOrderInfoDTOs && travelHotelOrderInfoDTOs.length && travelHotelOrderInfoDTOs[0].vendorsOrderStatus) &&
                      <Button type="primary" size="small" className="detail-btn" onClick={() => this.handleRefundZx(res.approvalNumber, 'hotel', zxUrl)}>{messages('dashboard.key128')/*查看详情*/}</Button>
                    }
                  </Col>
                  <Col span={4} className={res.isExtend ? 'type-stop' : 'type-city-city type-img-delete'}>
                    {
                      res.isExtend ? (<Button size="small" type="primary" loading={res.loading} onClick={(e) => stopAndStart(e, res, title, index)}>{res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}</Button>)
                        :
                        (res.loading ? <Button shape="circle" loading/>
                          :<Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                       onConfirm={() => dele(res, title, index)}
                                       okText={messages('request.key211'/*确定*/)}
                                       cancelText={messages('request.key175'/*取消*/)}>
                            <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                          </Popconfirm>)
                    }
                  </Col>
                </Row>
                <Row>
                  {res.remark && <div className="remark">{messages('common.remark')}：{res.remark}</div>}
                </Row>
                {beyondStandardReason && <Row className="standard-exceed">
                {excessiveMatters && excessiveMatters.length > 0 && <div className="title">{excessiveMatters[0]}</div>}{beyondStandardReason.split(';')[0] && <div>{messages('zx.exceed.reason'/*理由*/)}：{beyondStandardReason.split(';')[0]}</div>}
                {excessiveMatters && excessiveMatters.length > 0 && <div className="title">{excessiveMatters[1]}</div>}{beyondStandardReason.split(';')[1] && <div>{messages('zx.exceed.reason'/*理由*/)}：{beyondStandardReason.split(';')[1]}</div>}
                </Row>}
                {res.travelHotelOrderInfoDTOs && <TravelOrderList orderList={res.travelHotelOrderInfoDTOs} type="hotel"/>}
              </div>
            )
          }) }
      </div>)
    }
  },

  //同上，仅包含非TMC酒店行程
  getOfflineHotelRecordHeader(title, datas, click, dele, stopAndStart, start, isChangeVersion){
    if (datas.length > 0 && title === messages('mcd.cus.hotel'/*非TMC酒店*/)) {
      let titleImgUrl = this.setItineraryTypeImg(title);
      return (<span><img style={{marginTop:-4}} src={titleImgUrl}/>&nbsp;{title}</span>)
    }
  },
  getOfflineHotelRecordContent(title, datas, click, dele, stopAndStart, start, isChangeVersion){
    if (datas.length > 0 && title === messages('mcd.cus.hotel'/*非TMC酒店*/)) {
      return (<div>
        {
          datas.map((res, index) => {
            let dateF = moment(res.fromDate).format('YYYY.MM.DD') + " " + moment(res.fromDate).format('dddd');
            let dateL = moment(res.leaveDate).format('YYYY.MM.DD') + " " + moment(res.leaveDate).format('dddd');
            let startF = this.calculateDate(start, res.fromDate);
            let endL = this.calculateDate(start, res.leaveDate);
            let night = this.calculateDate(res.fromDate, res.leaveDate) - 1;
            return (
              <div key={title + index} className="type-line-box" onClick={() => click(res, title)}>
                <Row>
                  <Col span={6}>
                    <Tag color='#4B8DFF'>{messages('request.key462',{arg1:startF}/*第{arg1}天*/)}</Tag>~
                    <Tag color='#4B8DFF'>{messages('request.key462',{arg1:endL}/*第{arg1}天*/)}</Tag>
                  </Col>
                  <Col span={11}>{`${dateF}~${dateL}`}</Col>
                  <Col span={3}>{`${messages('request.key470',{arg1:night}/*{arg1}晚*/)}`}</Col>
                  <Col span={3} className="type-supply" style={{display: 'none'}}>
                    {res.supplierName && <img src={res.supplierIconUrl}/>}
                    {res.supplierName}
                  </Col>
                </Row>
                {
                  res.isExtend && res.disabled && <img className="stop-img" src={messages('request.key438'/*ZH*/) === 'EN' ? disabledImgEN : disabledImgZH}/>
                }
                <Row>
                  <Col span={12} className="type-city-city">
                    {messages('request.key337'/*目的地*/)}：
                    <span>{res.cityName ? res.cityName : messages('request.key490')/*不限*/}</span>
                  </Col>
                  <Col span={6} className="type-city-city">{res.approvalNumber && <div>{messages('request.key334'/*行程单号*/)}：{res.approvalNumber}</div>}</Col>
                  <Col span={6} className={res.isExtend ? 'type-stop' : 'type-city-city type-img-delete'}>
                    {
                      res.isExtend ? (<Button size="small" type="primary" loading={res.loading} onClick={(e) => stopAndStart(e, res, title, index)}>{res.disabled ? messages('request.key98'/*重新启用*/) : messages('request.key594')/*停用*/}</Button>)
                        :
                        (res.loading ? <Button shape="circle" loading/>
                          :<Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                       onConfirm={() => dele(res, title, index)}
                                       okText={messages('request.key211'/*确定*/)}
                                       cancelText={messages('request.key175'/*取消*/)}>
                            <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                          </Popconfirm>)
                    }
                  </Col>
                </Row>
                <Row>
                  {res.remark && <div className="remark">{messages('common.remark')}：{res.remark}</div>}
                </Row>
              </div>
            )
          }) }
      </div>)
    }
  },

  /**
   * 限制日期选择范围
   * @param current datePiceker的日期
   * @param start 设置的起始日期
   * @param end  设置的终止日期
   * @param days  终止日期往后延长天数
   * @returns {*|boolean}
     */
  disabledDate (current, start, end, floatEnd, floatStart, dateArray) {
    let boo = false;
    end = this.getAfterDate(floatEnd, end, 'utc');
    if(floatStart){
      start = this.getAfterDate(floatStart, start);
    }
    if (current < moment(start, 'YYYYMMDD') || current >= moment(end, 'YYYYMMDD hh:mm:ss')) {
      boo = true;
    }
    if(dateArray && dateArray.length>0){
      dateArray.map(dateStr => {
        if(current && current.format('YYYY-MM-DD') === dateStr){
          boo = true;
        }
      })
    }
    return current && boo;
  },

  /**
   * 差补行程记录折叠板
   * @param title 行程标题
   * @param datas 行程记录
   * @param click 进入编辑点击事件回调
   * @param dele  删除回调
   * @param displayDetail 展开明细回调
   * @param toBatchChange 批量更改回调
   * @param amountChange  金额变动监听回调
   * @param toSaveChange  批量或单项修改保存回调
   * @param toEditSubsidyItem  单项修改回调
   * @param searchByDate  根据日期查询差补明细回调
   * @param isHiddenItem  隐藏回调
   * @param isCancelHiddenItem  取消隐藏回调
     * @param subCtrlObj  页面控制量
     * @returns {XML}
     */
  getSubsidyRecordHeader(title, datas, click, dele, displayDetail, toBatchChange, amountChange, toSaveChange, toEditSubsidyItem, searchByDate, isHiddenItem, isCancelHiddenItem, subCtrlObj) {
    if (datas.length > 0) {
      let titleImgUrl = this.setItineraryTypeImg(title);
      return (<span><img style={{marginTop:-4}} src={titleImgUrl}/>&nbsp;{title}</span>)
    }
  },
  getSubsidyRecordContent(title, datas, click, dele, displayDetail, toBatchChange, amountChange, toSaveChange, toEditSubsidyItem, searchByDate, isHiddenItem, isCancelHiddenItem, subCtrlObj){
    if (datas.length > 0) {
      return (
        <div>
          {
            datas.map((res, index) => {
              let startDate = moment(res.startDate).format('YYYY-MM-DD');
              let endDate = moment(res.endDate).format('YYYY-MM-DD');
              let isShowDatePicker = startDate != endDate;
              let total = res.baseCurrency + " " + React.Component.prototype.filterMoney(res.totalBaseCurrencyAmount, queryCurrencyPrecision(res.baseCurrency), true) + "  ";
              let currentCodeMap = "";
              let codeNum = 0;//币种数；如果仅有一种币种且为本位币，则不显示后面的币种连加（currentMap）
              let codeStr = "";//第一种币种
              for (let key in res.currencyCodeAmountMap) {
                currentCodeMap = currentCodeMap + key + React.Component.prototype.filterMoney(res.currencyCodeAmountMap[key], queryCurrencyPrecision(key), true) + " + ";
                codeNum++;
                if(codeNum === 1){
                  codeStr = key;
                }
              }
              currentCodeMap = currentCodeMap.substr(0, currentCodeMap.length - 2);
              if(codeNum === 1 && codeStr === res.baseCurrency){
                currentCodeMap = '';
              }
              let remark = res.remark ? `${messages('request.key364'/*备注*/)}：${res.remark}` : '';
              let requestDTOs = res.travelSubsidiesRequestItemDTOs ? res.travelSubsidiesRequestItemDTOs : [];
              return (
                <div key={title+index} className="subsidy-record-css">
                  <div className="subsidy-line-box">
                    <Row className="set-font">
                      {`${startDate}~${endDate}`}<span style={{marginLeft:6,fontWeight: 'bold'}}>{res.cityName ? res.cityName : (
                        <span style={{color: '#d4d4d4'}}>{messages('request.key555')/*通用城市*/}</span>
                      )}</span>
                    </Row>
                    <Row>
                      <Col span={20}>
                        <span className="total">{total}</span>
                        <span className="currentMap">{currentCodeMap}</span>
                      </Col>
                      <Col span={4} className="type-img-delete" style={{display: 'none'}}>
                        {res.loading ?  <Button shape="circle" loading/>
                        :<Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                     onConfirm={() => dele(res, title, index)}
                                     okText={messages('request.key211'/*确定*/)}
                                     cancelText={messages('request.key175'/*取消*/)}>
                          <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                        </Popconfirm>}
                      </Col>
                    </Row>
                    <Row className="set-font">{remark}</Row>
                  </div>
                  <div style={{display: 'none'}}>
                    <Row>
                      <Col span={12}>
                        {
                          !res.isBatch && isShowDatePicker &&
                          <DatePicker
                            disabledDate={(c) => this.disabledDate(c, moment(res.startDate), moment(res.endDate), 1)}
                            onChange={(e) => searchByDate(e, index)}
                          />
                        }
                      </Col>
                      {!!requestDTOs.length && (
                        <Col span={12} className="save-cancel">
                          {
                            res.isBatch ? <div>
                                <Button onClick={() => toBatchChange(index)}>{messages('request.key175'/*取消*/)}</Button>
                                <Button loading={subCtrlObj.isSaveChange} onClick={() => toSaveChange(index)}>{messages('request.key442'/*保存*/)}</Button>
                              </div> : <Button onClick={() => toBatchChange(index)}>{messages('request.key443'/*批量更改*/)}</Button>
                          }
                        </Col>
                      )}
                    </Row>
                  </div>
                  {
                    requestDTOs.map((req, reqIndex)=> {
                      let displayItem = {index:index, reqIndex:reqIndex};
                      let currentCodeMapChiled = "";
                      let codeTypeCount = 0;
                      let firstCodeType = '';
                      let isShowCurrentCodeMapChiled = true;
                      for (let key in req.currencyCodeAmountMap) {
                        currentCodeMapChiled = currentCodeMapChiled + key + React.Component.prototype.filterMoney(res.currencyCodeAmountMap[key], queryCurrencyPrecision(key), true) + " + ";
                        codeTypeCount++;
                        if(codeTypeCount === 1){
                          firstCodeType = key;
                        }
                      }
                      if(codeTypeCount === 1 && firstCodeType === req.baseCurrencyCode){
                        isShowCurrentCodeMapChiled = false;
                      }
                      currentCodeMapChiled = currentCodeMapChiled.substr(0, currentCodeMapChiled.length - 2);
                      let totalChiled = req.baseCurrencyCode + " " + React.Component.prototype.filterMoney(req.baseCurrencyAmount, queryCurrencyPrecision(req.baseCurrencyCode), true);
                      let expenseTypeAmountMapChiled = "";
                      for (let key in req.expenseTypeAmountMap) {
                        expenseTypeAmountMapChiled = expenseTypeAmountMapChiled + key + React.Component.prototype.filterMoney(req.expenseTypeAmountMap[key], queryCurrencyPrecision(), true) + " + ";
                      }
                      expenseTypeAmountMapChiled = expenseTypeAmountMapChiled.substr(0, expenseTypeAmountMapChiled.length - 2);
                      let detailMaps = req.travelSubsidiesItemMap;//travelSubsidiesRequestItemDTOs.travelSubsidiesItemMap
                      let relativeRepeat = req.duplicateSubsidiesOIDs ? req.duplicateSubsidiesOIDs : [];
                      return (
                        <div className="second-box" key={title+index+reqIndex}>
                          {req.status == 1002 && <div className="to-hiden">
                            <span>{messages('request.key444'/*!隐藏该员工该行程下的所有差补，提交后将自动删除隐藏的差补*/)}</span>
                            <span onClick={() => isCancelHiddenItem(req, false)}>
                              {messages('request.key445'/*取消隐藏*/)}
                              <img src={require('images/travel/subsidy-hide.png')}/></span>
                          </div>}
                          <Row className="row-child">
                            <Col span={6}>
                              <img className="user-icon" src={req.avatar ? req.avatar : require("images/travel/empty.avatar.jpg")}/>
                              <span>{req.fullName}</span>
                            </Col>
                            <Col span={14}>
                              {
                                isShowCurrentCodeMapChiled && <Tooltip title={currentCodeMapChiled} placement="top">
                                  <Row className="child-map">{currentCodeMapChiled}</Row>
                                </Tooltip>
                              }
                              <Row className="child-map">{totalChiled}</Row>
                              <Tooltip placement="top" title={expenseTypeAmountMapChiled}>
                                <Row className="child-map">{expenseTypeAmountMapChiled}</Row>
                              </Tooltip>
                            </Col>
                            <Col span={4} className="display-icon">
                              <Icon type={req.isDisplay ? 'down-circle-o' : 'right-circle-o'}
                                    onClick={() => displayDetail(index, reqIndex)}/>
                            </Col>
                            <Col span={4} className="display-icon-dele" style={{display: 'none'}}>
                              {
                                !res.isBatch && (
                                  <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                              onConfirm={() => isHiddenItem(req, false)}
                                              okText={messages('request.key211'/*确定*/)}
                                              cancelText={messages('request.key175'/*取消*/)}>
                                    <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                                  </Popconfirm>
                                )
                              }
                            </Col>
                          </Row>
                          {
                            req.isDisplay && detailMaps.map((det, detIndex)=> {/* TODO 需要一个控制显示的量 */
                              return det.travelSubsidiesRequestItemDetailDTOs.map((detail, indexOf)=> {
                                let date = moment(detail.subsidiesDate).format('MM-DD');
                                let rateMount =  messages('request.key342'/*企业汇率*/)+ ": ";
                                let isRepeat = false;
                                relativeRepeat.map(repeat => {//检验是否重复
                                  if (detail.travelSubsidiesDetailsOID == repeat) {
                                    isRepeat = true;
                                  }
                                })
                                let calculateChar = ' + ';
                                if(detail.currencyRate - detail.baseCurrencyRate < 0){
                                  calculateChar = ' - ';
                                }
                                let tempRate = Math.abs(detail.currencyRate - detail.baseCurrencyRate) / detail.baseCurrencyRate * 100;
                                rateMount = rateMount + detail.baseCurrencyRate.toFixed(2) + calculateChar + tempRate.toFixed(1)
                                  + `% , ${messages('request.key343'/*原金额*/)}: `
                                  + React.Component.prototype.filterMoney(detail.baseAmount, queryCurrencyPrecision(detail.currencyCode), true);
                                return (
                                  <div className="subsidy-detail" key={detail.travelSubsidiesDetailsOID}>
                                    {detail.status == 1002 && <div className="to-hiden">
                                      <span>{messages('request.key446'/*!隐藏的差补在提交后将自动删除*/)}</span>
                                      <span onClick={() => isCancelHiddenItem(detail, true, displayItem)}>
                                        {messages('request.key445'/*取消隐藏*/)}
                                        <img src={require('images/travel/subsidy-hide.png')}/></span>
                                    </div>}
                                    <Spin spinning={subCtrlObj.isSaveChange}>
                                      <Row>
                                        <Col span={3}>{date}</Col>
                                        <Col span={12} className="child-map-detail">
                                          {
                                            isRepeat && <Tag color="#f50">{messages('request.key341'/*重复*/)}</Tag>
                                          }
                                          {detail.expenseTypeName}</Col>
                                        <Col span={2} className="text-center">{detail.currencyRate.toFixed(2)}</Col>
                                        <Col span={2} className="text-center">{detail.currencyCode}</Col>
                                        {
                                          res.isBatch ? <Col span={5}>
                                            {
                                              subCtrlObj.isCanMore ? <InputNumber
                                                onChange={(e) => amountChange(index, reqIndex, detIndex, indexOf, e)} min={0}
                                                defaultValue={detail.amount}/> :
                                                <InputNumber min={0}
                                                             onChange={(e) => amountChange(index, reqIndex, detIndex, indexOf, e)}
                                                             precision={queryCurrencyPrecision(detail.currencyCode)}
                                                             max={detail.baseAmount} defaultValue={detail.amount}/>
                                            }

                                          </Col> :
                                            <Col span={2} className="text-center">{React.Component.prototype.filterMoney(detail.amount, queryCurrencyPrecision(detail.currencyCode), true)}</Col>
                                        }
                                        {
                                          !res.isBatch && <Col span={2} className="display-icon-eye-edit text-center">
                                            <img className="img-edit" onClick={() => toEditSubsidyItem(detail, res.cityName, displayItem)}
                                                 src={require('images/travel/subsidy-edit.png')}/>
                                          </Col>
                                        }
                                        {
                                          false && !res.isBatch && <Col span={3} className="display-icon-eye-dele text-center" style={{display: 'none'}}>
                                            <Popconfirm title={messages('request.key321'/*你确定删除这行内容吗?*/)}
                                                        onConfirm={() => isHiddenItem(detail, true, displayItem)}
                                                        okText={messages('request.key211'/*确定*/)}
                                                        cancelText={messages('request.key175'/*取消*/)}>
                                              <Icon type="close-circle" onClick={(e) => {e.stopPropagation()}}/>
                                            </Popconfirm>
                                          </Col>
                                        }
                                      </Row>
                                      <Row style={{marginTop:6}}>
                                        <Col span={3}></Col>
                                        <Col span={19}>{rateMount}</Col>
                                      </Row>
                                      {
                                        detail.comment && <Row style={{marginTop:6}}>
                                          <Col span={3}></Col>
                                          <Col span={19} style={{wordBreak: 'break-all'}}>{messages('request.key364'/*备注*/)+"：" + detail.comment}</Col>
                                        </Row>
                                      }
                                    </Spin>
                                  </div>
                                )
                              })
                            })
                          }
                        </div>
                      )
                    })
                  }
                </div>
              )
            })
          }
        </div>
      )
    }
  },

  /**
   * 设置行程类型的图标路径
   * @param typeNum 行程类号码
   * @returns {*}
   * 这个方法也太傻了，好气啊，一定要抽时间改了
   */
  setItineraryTypeImg(typeNum){
    let imgUrl = null;
    switch (typeNum) {
      case 'FLIGHT':
        imgUrl = require("images/travel/icon-plane.png");
        break;
      case 'TRAIN':
        imgUrl = require("images/travel/icon-train.png");
        break;
      case 'HOTEL':
      case 'OFFLINE_HOTEL':
        imgUrl = require("images/travel/hotel.png");
        break;
      case 'OTHER':
        imgUrl = require("images/travel/icon-other.png");
        break;
      case 'SUBSIDY':
        imgUrl = require("images/travel/subsidy.png");
        break;
      default:
        break;
    }
    if (imgUrl) {
      return imgUrl;
    }
    switch (typeNum) {
      case 1001:
        imgUrl = require("images/travel/icon-plane.png");
        break;
      case 1002:
        imgUrl = require("images/travel/icon-train.png");
        break;
      case 1003:
      case 1011:
        imgUrl = require("images/travel/hotel.png");
        break;
      case 1004:
        imgUrl = require("images/travel/icon-other.png");
        break;
      case 1006:
        imgUrl = require("images/travel/subsidy.png");
        break;
      default:
        break;
    }
    switch (typeNum) {
      case '酒店':
      case 'TMC酒店':
      case '非TMC酒店':
      case 'offlineHotel':
      case 'Hotel':
      case messages('mcd.cus.hotel'/*非TMC酒店行程*/):
        imgUrl = require("images/request/travel/hotel.png");
        break;
      case '机票':
      case 'TMC机票':
      case 'airline':
      case 'Ticket':
        imgUrl = require("images/request/travel/plane.png");
        break;
      case '火车':
      case 'Train':
        imgUrl = require("images/request/travel/train.png");
        break;
      case '差补':
      case '差旅餐饮/洗衣费':
      case 'subsidy':
      case 'Subsidy':
        imgUrl = require("images/request/travel/subsidy.png");
        break;
      case '其他':
      case 'Other traffic':
        imgUrl = require("images/request/travel/other.png");
        break;
      case '备注':
      case 'Itinerary remark':
        imgUrl = require("images/request/travel/remark.png");
        break;
      case 'urban':
      case 'water':
        imgUrl = require("images/travel/car.png");
      default:
        break;
    }
    return imgUrl;
  },

  /**
   * 根据某天计算该天之后的n天日期
   * @param baseDate 参照日期
   * @param relativeDate 相对参照日期之后的天数 整数且大于0
   * @returns {number}
   */
  calculateDate(baseDate, relativeDate){
    let days = 0;
    if(baseDate && relativeDate){
      let base = moment(baseDate).format('YYYY-MM-DD');
      let relative = moment(relativeDate).format('YYYY-MM-DD');
      let newBase = new Date(base);
      let newRelative = new Date(relative);
      let newBaseTime = newBase.getTime();
      let newRelativeTime = newRelative.getTime();
      if (newRelativeTime > newBaseTime) {
        days = (newRelativeTime - newBaseTime) / (24 * 60 * 60 * 1000);
      }
    }
    return days + 1;
  },

  //获取星期几
  getWeed(value){
    switch(value){
      case 0:
        return messages('request.key33'/*周日*/);
      case 1:
        return messages('request.key34'/*周一*/);
      case 2:
        return messages('request.key35'/*周二*/);
      case 3:
        return messages('request.key36'/*周三*/);
      case 4:
        return messages('request.key37'/*周四*/);
      case 5:
        return messages('request.key38'/*周五*/);
      case 6:
        return messages('request.key39'/*周六*/);
    }
  }
}
